package com.evan.alip7.completablefuture;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author huangzhongliang
 * @time 2023/08/28 10:43
 */
public class CompletableFutureDemo {
    //Thread
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> stringFutureTask = new FutureTask<>(new MyThread2());
        Thread t1 = new Thread(stringFutureTask, "t1");
        t1.start();

        //    取结果
        System.out.println("stringFutureTask.get() = " + stringFutureTask.get());

    }


    static class MyThread2 implements Callable<String> {
        @Override
        public String call() throws Exception {
            System.out.println("进入Callable异步线程");
            return "hello evan";
        }
    }

}
